package com.entity;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.*;

import java.io.Serializable;

public class Student implements Serializable, BeanNameAware, BeanFactoryAware, InitializingBean, DisposableBean {

    private String beanName;

    Logger logger = LoggerFactory.getLogger(getClass());

    private static final long serialVersionUID = 1L;
    private String name;
    private Integer age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        logger.info("===============Student.setName方法设置名字:{}===============", name);
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Student() {
        logger.info("===============Student构造器===============");
    }

    public Student(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public void studentInitMetohd(){
        logger.info("===============initMethod>>>>studentInitMetohd===============");
    }

    public void studentDestroyMetohd(){
        logger.info("===============destroyMethod>>>>studentDestroyMetohd===============");
    }

    @Override
    public void setBeanName(String name) {
        logger.info("===============BeanNameAware.setBeanName===============");
        this.beanName = name;

    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        logger.info("===============BeanFactoryAware.setBeanFactory===============");

    }

    @Override
    public void afterPropertiesSet() throws Exception {
        logger.info("===============InitializingBean.afterPropertiesSet===============");
    }

    @Override
    public void destroy() throws Exception {
        logger.info("===============DisposableBean.destroy===============");
    }
}
